<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<s:set var="PUBLIC_EVENT_CATEGORY_LIST" value="%{#request.PUBLIC_EVENT_CATEGORY_LIST}" />
<s:set var="FOLLOWING_PUBLIC_EVENT_LIST" value="%{#request.FOLLOWING_PUBLIC_EVENT_LIST}" />
<s:set var="EMPTY_LIST" value="%{#request.EMPTY_LIST}" />

<s:iterator var="event_iter" value="%{#PUBLIC_EVENT_CATEGORY_LIST}"status="eventCounter">
<s:iterator var="following_iter" value="%{#FOLLOWING_PUBLIC_EVENT_LIST}" status="followingCounter">
<s:if test="#eventCounter.count == #followingCounter.count">
	<div class="row deliverEvent panel panel-primary">								
		<div class="row">
			<div class="col-md-9">
				<a	href="PublicEventDetail.do?id=${event_iter.eventId}">
					<span style="font-size: 19"><b> ${event_iter.title}</b></span>
				</a>
			</div>
			<div class="col-md-3">
				<c:if test="${!empty(following_iter) }">
					<input type="button" onclick="changeFollowing(${following_iter.followingId},${event_iter.eventId},this)" 
					value="Hủy theo dõi"  class="btn btn-danger btn-xs" style="width:125px;"/>
				</c:if> 
		
				<c:if test="${empty(following_iter) }">
					<input type="button" onclick="changeFollowing('',${event_iter.eventId},this)" 
						value="Theo dõi" class="btn btn-success btn-xs" style="width:125px;"/>
				</c:if>
			</div>
		</div>
		<div class="row">
			<div class="col-md-3"><b>Người tạo: </b> </div>
			<div class="col-md-7">${event_iter.account.fullname}</div>
		</div>
			<div class="row">
					<div class="col-md-3"><b>Thể loại: </b> </div>
					<div class="col-md-7">
					
						<s:if test="%{#event_iter.location == ''}">
						Chưa cập nhật
					</s:if>
					<s:else>
							<s:property value="%{#event_iter.eventcategory.eventCategoryName}"/>
					</s:else>
					</div>
				</div>
		<div class="row">
			<div class="col-md-3"><b>Địa điểm: </b> </div>
			<div class="col-md-9">${event_iter.location}</div>
		</div>
		<div class="row">
			<div class="col-md-3"><b>Thời gian diễn ra: </b> </div>
			<div class="col-md-7">
				<fmt:parseDate value="${event_iter.startTime}" pattern="yyyy-MM-dd'T'HH:mm:ssZ" var="start" />
				<fmt:parseDate value="${event_iter.endTime}" pattern="yyyy-MM-dd'T'HH:mm:ssZ" var="stop" />
				<div class="row">
					<div class="col-md-12">
					Từ 
					<s:if test="%{#event_iter.isAllDayEvent}">
						<fmt:formatDate value="${start}" pattern="'ngày' dd 'tháng' MM 'năm' yyyy" />
					</s:if>
					<s:else>
						<fmt:formatDate value="${start}" 
						pattern="HH 'giờ' mm 'phút, ngày' dd 'tháng' MM 'năm' yyyy" />
					</s:else>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
					Đến 
					<s:if test="%{#event_iter.isAllDayEvent}">
						<fmt:formatDate value="${stop}" pattern="'ngày' dd 'tháng' MM 'năm' yyyy" />
					</s:if>
					<s:else>
						<fmt:formatDate value="${stop}" 
						pattern="HH 'giờ' mm 'phút, ngày' dd 'tháng' MM 'năm' yyyy" />
					</s:else>
					</div>
				</div>
			</div>	
		</div>
		<div class="row">
			<div class='deliverLine'></div>
			<div class="col-md-11"><b>Mô tả: </b> 
				<s:if test="%{#event_iter.description != ''}">${event_iter.description}</s:if>
				<s:else>Không có mô tả!</s:else>
			</div>
		</div>
	</div>
</s:if>
</s:iterator>
</s:iterator>
<s:if test="%{#EMPTY_LIST == true}">
empty
</s:if>